<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 1. 引入 css和js -->
    <link rel="stylesheet" href="../swiper/swiper-bundle.min.css">
    <script src="../swiper/swiper-bundle.min.js"></script>
    <style>
        /* 3. 定义swiper容器大小 */
        .swiper-1 {
            width: 1226px;
            /* height: 500px; */
            margin: 50px auto;
        }

        .swiper-1  img{
            width: 100%;
        }
    </style>
</head>

<body>
    <!-- 2. 添加swiper的html结构 -->
    <div class="swiper swiper-1">
        <div class="swiper-wrapper">
            <!-- <div class="swiper-slide">Slide 1</div>
            <div class="swiper-slide">Slide 2</div>
            <div class="swiper-slide">Slide 3</div> -->
            <div class="swiper-slide"><img src="../images/1.webp" alt=""></div>
            <div class="swiper-slide"><img src="../images/2.webp" alt=""></div>
            <div class="swiper-slide"><img src="../images/3.webp" alt=""></div>
            <div class="swiper-slide"><img src="../images/4.webp" alt=""></div>
        </div>
        <!-- 如果需要分页器 -->
        <div class="swiper-pagination"></div>

        <!-- 如果需要导航按钮 -->
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>

        <!-- 如果需要滚动条 -->
        <!-- <div class="swiper-scrollbar"></div> -->
    </div>
</body>
<script>
    // 4. 初始化swiper  => 创建swiper实例(让对应的swiper动起来)
    var mySwiper = new Swiper('.swiper-1', {
        // 基础配置
        // direction: 'vertical', // 垂直切换选项(默认水平)
        loop: true, // 循环模式选项(循环切换  默认false)


        // 组件配置
        // autoplay:true,
        autoplay:{
            delay:3000, // 自动切换的时间间隔，单位ms
            pauseOnMouseEnter:true,
        },

        // 如果需要分页器
        pagination: {  // 导航
            el: '.swiper-pagination',
            hideOnClick:true,  // 点击隐藏/显示分页器
            clickable:true, // 点击分页器的指示点分页器会控制Swiper切换
        },

        // 如果需要前进后退按钮
        navigation: {
            nextEl: '.swiper-button-next',   //  设置前进按钮的css选择器或HTML元素。
            prevEl: '.swiper-button-prev',   //  设置后退按钮的css选择器或HTML元素。
            hideOnClick:true,
        },

        // 如果需要滚动条
        // scrollbar: {
        //     el: '.swiper-scrollbar',
        // },
    })

</script>

</html>